export interface Authority {
  authority: string
}

export interface User {
  username: string
  nickname: string
  authorities: Array<Authority>
}

class UserService implements User {
  username: string = ''
  nickname: string = ''
  authorities: Array<Authority> = []

  isLoggin (): boolean {
    return !!this.username
  }

  hasRole (roles: Array<string>): boolean {
    return roles.every(role =>
      this.authorities.some(auth => auth.authority === role)
    )
  }
}

export default new UserService()
